package com.misty.proxy_pattern.client1_static.static_proxy;

import com.imist.proxy_pattern.client1_static.IOrderService;
import com.imist.proxy_pattern.client1_static.Order;

public class OrderServiceProxy implements IOrderService {

    private IOrderService iOrderService;

    public OrderServiceProxy(IOrderService iOrderService) {
        this.iOrderService = iOrderService;
    }

    @Override
    public int saveOrder(Order order) {
        //方法增强
        before();
        //执行修改的业务逻辑
        System.out.println("保存订单信息：" + order.getOrderInfo());
        int id = iOrderService.saveOrder(order);
        after();
        return id;
    }

    private void before() {
        System.out.println("静态代理 before ");
    }

    private void after() {
        System.out.println("静态代理 after ");
    }
}
